package edu.njust.LabSystem.Service;

import edu.njust.LabSystem.dao.ISeat;
import edu.njust.LabSystem.entity.MybatisUtil;
import edu.njust.LabSystem.entity.Seat;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class SeatService {
	public Seat getSeatById(String id) {
		SqlSession sqlSession=MybatisUtil.getSqlSession();
		
		ISeat Iseat=sqlSession.getMapper(ISeat.class);
		Seat seat=Iseat.getSeatById(id);
				
		sqlSession.close();
		
		return seat;
	}
	public List<Seat> getSeatsById(String lid) {
		SqlSession sqlSession=MybatisUtil.getSqlSession();
		
		ISeat Iseat=sqlSession.getMapper(ISeat.class);
		List<Seat> seats=Iseat.getSeatsById(lid);
				
		sqlSession.close();
		
		return seats;
	}

	public Boolean updateSeat(String sid,String is_taken) {

		SqlSession sqlSession=MybatisUtil.getSqlSession();

		ISeat Iseat=sqlSession.getMapper(ISeat.class);
		Boolean b=Iseat.updateById(sid,is_taken);

		sqlSession.close();

		return b;
	}
}
